package com.hottop.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hottop.common.annotation.Log;
import com.hottop.common.core.controller.BaseController;
import com.hottop.common.core.domain.AjaxResult;
import com.hottop.common.enums.BusinessType;
import com.hottop.system.domain.TBaiduhot;
import com.hottop.system.service.ITBaiduhotService;
import com.hottop.common.utils.poi.ExcelUtil;
import com.hottop.common.core.page.TableDataInfo;

/**
 * 百度热搜Controller
 * 
 * @author ruoyi
 * @date 2022-02-19
 */
@RestController
@RequestMapping("/system/baiduhot")
public class TBaiduhotController extends BaseController
{
    @Autowired
    private ITBaiduhotService tBaiduhotService;

    /**
     * 查询百度热搜列表
     */
    @PreAuthorize("@ss.hasPermi('system:baiduhot:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBaiduhot tBaiduhot)
    {
        startPage();
        List<TBaiduhot> list = tBaiduhotService.selectTBaiduhotList(tBaiduhot);
        return getDataTable(list);
    }

    /**
     * 导出百度热搜列表
     */
    @PreAuthorize("@ss.hasPermi('system:baiduhot:export')")
    @Log(title = "百度热搜", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBaiduhot tBaiduhot)
    {
        List<TBaiduhot> list = tBaiduhotService.selectTBaiduhotList(tBaiduhot);
        ExcelUtil<TBaiduhot> util = new ExcelUtil<TBaiduhot>(TBaiduhot.class);
        util.exportExcel(response, list, "百度热搜数据");
    }

    /**
     * 获取百度热搜详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:baiduhot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tBaiduhotService.selectTBaiduhotById(id));
    }

    /**
     * 新增百度热搜
     */
    @PreAuthorize("@ss.hasPermi('system:baiduhot:add')")
    @Log(title = "百度热搜", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBaiduhot tBaiduhot)
    {
        return toAjax(tBaiduhotService.insertTBaiduhot(tBaiduhot));
    }

    /**
     * 修改百度热搜
     */
    @PreAuthorize("@ss.hasPermi('system:baiduhot:edit')")
    @Log(title = "百度热搜", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBaiduhot tBaiduhot)
    {
        return toAjax(tBaiduhotService.updateTBaiduhot(tBaiduhot));
    }

    /**
     * 删除百度热搜
     */
    @PreAuthorize("@ss.hasPermi('system:baiduhot:remove')")
    @Log(title = "百度热搜", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tBaiduhotService.deleteTBaiduhotByIds(ids));
    }
}
